package com.haoxi.gateway.test.message;

import com.haoxi.gateway.test.SGIPConstant;
import com.haoxi.gateway.test.util.TypeConvert;

public class SGIPReportRepMessage extends SGIPMessage {
    private int result;

    public SGIPReportRepMessage(byte[] buf) throws IllegalArgumentException {
        super.buf = new byte[29];
        if (buf.length != 29) {
            throw new IllegalArgumentException(SGIPConstant.SMC_MESSAGE_ERROR);
        } else {
            System.arraycopy(buf, 0, super.buf, 0, 29);
            message_Length = TypeConvert.byte2int(super.buf, 0);
            command_ID = TypeConvert.byte2int(super.buf, 4);
            src_node_Id = TypeConvert.byte2int(super.buf, 8);
            time_Stamp = TypeConvert.byte2int(super.buf, 12);
            sequence_Id = TypeConvert.byte2int(super.buf, 16);
            result = buf[20];
        }
    }

    public int getResult() {
        return result;
    }

    public int getMsgLen() {
        return this.message_Length;
    }

    public int getSrcNodeId() {
        return src_node_Id;
    }

    public int getTimeStamp() {
        return time_Stamp;
    }

    public String toString() {
        String tmpStr = "SGIP_REPORT_REP: ";
        tmpStr = String.valueOf(String.valueOf((new StringBuffer(String
                .valueOf(String.valueOf(tmpStr)))).append("\r\nmessage_Length=")
                .append(getMsgLen())));
        tmpStr = String.valueOf(String.valueOf((new StringBuffer(String
                .valueOf(String.valueOf(tmpStr)))).append("\r\nCommandId=").append(
                getCommandId())));
        tmpStr = String.valueOf(String.valueOf((new StringBuffer(String
                .valueOf(String.valueOf(tmpStr)))).append("\r\nSrcNodeId=").append(
                getSrcNodeId())));
        tmpStr = String.valueOf(String.valueOf((new StringBuffer(String
                .valueOf(String.valueOf(tmpStr)))).append("\r\nTimeStamp=").append(
                getTimeStamp())));
        tmpStr = String.valueOf(String.valueOf((new StringBuffer(String
                .valueOf(String.valueOf(tmpStr)))).append("\r\nSequence_Id=")
                .append(getSequenceId())));
        tmpStr = String.valueOf(String.valueOf((new StringBuffer(String
                .valueOf(String.valueOf(tmpStr)))).append("\r\nResult=").append(
                getResult())));
        return tmpStr;
    }

    public int getCommandId() {
        return command_ID;
    }

    public int getallLength() {
        return TypeConvert.byte2int(buf, 0);
    }
}
